<?php


$tdon = isset($_REQUEST['donation'])?$_REQUEST['donation']:'';
// -- webMS Modification --
  // Ensure a valid runtime environment or die
  if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );

  // -- webMS Modification --
  // Check if osCommerce environment is already loaded
  if (defined( '_OSCOMMERCE_LOADED' )) {
    if (!DB_SHARED) {
      // Reconnect to osCommerce Database
      tep_db_connect() or die('Unable to connect to database server!');
    }
    // Load osCommerce Globals for Boxes
    global $category_links, $languages_id, $catID, $catID_array, $current_category_id;
    global $request_type, $lng, $cart, $currencies, $language, $navigation, $breadcrumb;
  } else {
    // Load osCommerce Environment for the First Time
    require('components/'.$option.'/includes/application_top.php');
  }
require(DIR_WS_LANGUAGES . $language . '/' . 'donate.php');
$breadcrumb->add(TEXT_DONATE);
?>

<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->


<table  width="100%"  cellspacing="0" cellpadding="0" >
  <tr class="header">
    <td class="headerNavigation" width="10">
   </td>
    <td class="contentheading"><?PHP echo TEXT_DONATION_HEADER; ?></td>
    </tr>
</table>
<table border="0" width="100%" cellspacing="0" cellpadding="1" class="modBox">
  <tr>
    <td>
<table width="100%" border="0" cellpadding="4" cellspacing="4" class="modBoxContents">
<tr>
  <td class="boxtext" valign="top">
<?php
if (strcmp ($_REQUEST['action'], 'err') != 0)
{
	$price = $_REQUEST['donation'];
	$cart_quantity = 2;
}
switch ($_REQUEST['action'])
  {
  	case 'add_to_cart': 
  	
  //	print_r($currencies);
  //	echo $currencies->get_value($currency);
  $price = $price / $currencies->get_value($currency);
  
  	//die($price);
  	
        echo tep_draw_form('cart_quantity', tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=add_product'));
     	tep_db_query("insert into  " . TABLE_PRODUCTS . " (products_id, products_quantity, products_model, products_image, products_price, products_date_added, products_last_modified, products_date_available, products_weight, products_status, products_tax_class_id, manufacturers_id, products_ordered) values ('', '2', '" . strtotime("now") . "', '', '" . $price ."', '', '0', '1', '1', '1', '1', '', '')");
      	$pid= tep_db_insert_id();
       	tep_db_query("insert into " . TABLE_PRODUCTS_DESCRIPTION . "(products_id, language_id, products_name, products_description, products_url, products_viewed) values ('" . $pid . "', '1', 'Donation', 'Donation', '', '')");
       	
		$products_id = $pid;
		echo '<table  width="100%"  cellspacing="0" cellpadding="0" >' .
		'<tr><td>'.TEXT_DONATION_CONFIRM.'</tr>' . 
		'<tr>'.$currencies->display_price($price, 0) .'</tr>';
		echo '<tr><td>' . tep_draw_hidden_field('cart_quantity', $cart_quantity) . '</td>';
  	    echo '<td>' .tep_draw_hidden_field('products_id', $products_id) . tep_draw_hidden_field('quantity','1') . '</td></tr>';
		echo '<tr><td colspan=2 align=right>' . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART) . '</td></tr></table></form>';
	break;
	case '':
		
        	echo tep_draw_form('cart_quantity', tep_href_link('donate.php', tep_get_all_get_params(array('action')) . 'action=add_to_cart'));
			echo  TEXT_INFORMATION_DONATE ;
	   		echo '<br>'. tep_draw_input_field('donation','').'<br>';
			//echo $domname;
	        echo '&nbsp;'. tep_image_submit('button_donate.gif', TEXT_DONATE);
		
		
	break;
	
 }
 ?>
 </form>
</td>
</tr>
</table>
</td>
</tr>
</table> 


<!-- body_text_eof //-->



<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<br>
<?php
  require(DIR_WS_INCLUDES . 'application_bottom.php');

  // -- webMS Modification --
  // reset the Mambo Database connection (stomped by osCommerce Connection)
  if (!DB_SHARED) {
    global $database, $mosConfig_host, $mosConfig_user, $mosConfig_password, $mosConfig_db, $mosConfig_dbprefix;
    $database = new database( $mosConfig_host, $mosConfig_user, $mosConfig_password, $mosConfig_db, $mosConfig_dbprefix );
  }
 ?>
